#pragma once
#include <pthread.h>
#include <semaphore.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>

namespace os
{
	//====================================================
	//CLASS : 	Mutex
	//DESCR.: 	Encapsulates Mutex functionality
	//====================================================
	class Mutex
	{
	public:
		Mutex();
		~Mutex();
		void signal();
		void wait();

	private:
		pthread_mutex_t id;
	};


	//=====================================
	// CLASS : Thread
	// DESCR.: Wraps thread functionality
	//=====================================
	class Thread
	{
	public:
		// Thread priorities
		enum ThreadPriority
		{
			PRIORITY_LOW          = 1,
			PRIORITY_BELOW_NORMAL = 25,
			PRIORITY_NORMAL       = 50,
			PRIORITY_ABOVE_NORMAL = 75,
			PRIORITY_HIGH         = 99,
		};

		Thread(ThreadPriority pri = Thread::PRIORITY_NORMAL, std::string nme = "");
		~Thread();

		void start();
		ThreadPriority getPriority();
		std::string getName();
		virtual void run() = 0;

	private:
		pthread_attr_t prioAtt;
		ThreadPriority priority;
		std::string name;
		pthread_t handle;
		static void* threadMapper(void* att);
	};
}
